<template>
  <div class="form-components" :style="newStyle">
    <div v-if="$attrs.readonly || $attrs.onlyShow" class="form-readonly" />
    <el-switch v-model="formValue" v-bind="$attrs" @change="onChange" />
  </div>
</template>

<script>
import { comMixin } from "../../../utils/comMixins";
export default {
  mixins: [comMixin],
  name: "form-switch",
  model: {
    prop: "value", // 绑定的值，通过父组件传递
    event: "update",
  },
  props: {
    modelValue: {
      type: [Boolean, String, Number],
      default: false,
    },
  },
  computed: {
    formValue: {
      get() {
        return this.modelValue;
      },
      set(val) {
        this.$emit("update: modelValue", val);
      },
    },
  },
};
</script>

<style lang="scss" scoped>
</style>